<template>
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>
    <div style="margin-left: 10px;">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px"
        style="margin-top: 10px;">
        <!--<el-form-item label="发货通知编号" prop="tongzhiNo">
          <el-input v-model="queryParams.tongzhiNo" placeholder="请输入发货通知编号" />
        </el-form-item>-->
        <el-form-item label="发货单号" prop="fahuoNo">
          <el-input v-model="queryParams.fahuoNo" placeholder="请输入发货单号" />
        </el-form-item>
        <el-form-item label="订单编号" prop="proNo">
          <el-input v-model="queryParams.proNo" placeholder="请输入订单编号" />
        </el-form-item>
        <el-form-item label="产品编号" prop="nos">
          <el-input v-model="queryParams.nos" placeholder="请输入产品编号" />
        </el-form-item>
        <el-form-item label="产品名称" prop="name">
          <el-input v-model="queryParams.name" placeholder="请输入产品名称" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <!-- @selection-change="handleSelectionChange" -->
      <el-table border v-loading="loading" :data="columns" ref="table" :max-height="tableMaxHeight" @sort-change="handleSortChange">
        <!-- <el-table-column type="selection" width="55" align="center"/>-->
      <!--  <el-table-column sortable label="发货通知编号" align="center" prop="tongzhiNo" show-overflow-tooltip />-->
        <el-table-column sortable label="发货单号" align="center" prop="fahuoNo" show-overflow-tooltip />
        <el-table-column sortable label="发货状态" align="center" prop="status">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.yifahuo_status" :value="scope.row.status" />
          </template>
        </el-table-column>
        <el-table-column sortable label="交货日期" align="center" prop="jiaohuoDate" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.jiaohuoDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column sortable label="发货日期" align="center" prop="fahuoDate" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.fahuoDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column label="采购单号" align="center" prop="caigouNo"/>
               <el-table-column label="供货单号" align="center" prop="gonghuoNo"/>-->
        <el-table-column sortable label="订单编号" align="center" prop="proNo" show-overflow-tooltip />
        <el-table-column sortable label="产品编号" align="center" prop="nos" show-overflow-tooltip />
        <el-table-column sortable label="产品名称" align="center" prop="name" show-overflow-tooltip />
        <el-table-column sortable label="产品型号" align="center" prop="models" show-overflow-tooltip />
        <!--<el-table-column label="产品明细" align="center" prop="mingxi"/>-->
        <el-table-column sortable label="单位" align="center" prop="danwei" />
        <el-table-column sortable label="产品单价" align="center" prop="danjian" />
        <el-table-column sortable label="发货数量" align="center" prop="shuliang" />
        <el-table-column sortable label="发货金额" align="center" prop="money" />
        <el-table-column label="备注" align="center" prop="remark" />
      </el-table>

    </div>
    <!--<fahuomingxi-list ref="fahuomingxiList" @ok="getList"></fahuomingxi-list>-->
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {
    getAction,
    addAction,
    getById
  } from '@/api/manage'

  export default {
    name: "YiFahuoBySaleList",
    dicts: ['yifahuo_status'],
    components: {},
    data() {
      return {
        title: "产品发货明细",
        open: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        rows: [],
        rules: {},
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 销售信息管理表格数据
        dataList: [],
        columns: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 20000,
          tongzhiId: null,
          tongzhiNo: null,
          jiaohuoDate: null,
          caigouNo: null,
          gonghuoNo: null,
          proId: null,
          proNo: null,
          prodName: null,
          saleId: null,
          name: null,
          models: null,
          mingxi: null,
          nos: null,
          danwei: null,
          danjian: null,
          shuliang: null,
          money: null,
          status: null,
          fahuoId: null,
          fahuoNo: null,
          params: {},
        },
        url: {
          list: '/lvYifahuomingxi/lvYifahuomingxi/list',
        },
        tableMaxHeight: window.innerHeight - 320,
      };
    },
    created() {
      // this.intDictsForPrj();
      window.addEventListener('resize', this.getTableHeight);
    },
    destroyed() {
      window.removeEventListener('resize', this.getTableHeight);
    },
    methods: {
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      getTableHeight() {
        this.tableHeight = window.innerHeight - 320
      },
      yiFahuoBySaleShow(row) {
        this.queryParams.saleId = row.id;
        this.open = true;
        this.getList();
      },
      /** 查询销售信息管理列表 */
      getList() {
        this.loading = true;
        getAction(this.url.list, this.queryParams).then(response => {
          this.columns = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
       /** 排序触发事件 */
      handleSortChange(column, prop, order) {
        this.queryParams.orderByColumn = column.prop;
        this.queryParams.isAsc = column.order;
        this.handleQuery();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.params = {}
        this.resetForm("queryForm");
        this.handleQuery();
      },
    }
  };
</script>
